<template>
  <van-cell
    :to="{ name: 'art', params: { aid: art.art_id } }"
    class="article-item"
  >
    <!-- 标题插槽 -->
    <div slot="title" class="title van-multi-ellipsis--l2">{{ art.title }}</div>
    <!-- 默认插槽： 放右侧图片 -->
    <van-image
      slot="default"
      class="right-cover"
      fit="cover"
      v-if="art.cover.type === 1"
      :src="art.cover.images[0]"
    />
    <!-- 描述插槽： 放文章评论作者... + 3张图片 -->
    <template slot="label">
      <!-- 3张图片 -->
      <div class="cover-wrap" v-if="art.cover.type === 3">
        <van-image
          v-for="(img, i) in art.cover.images"
          :key="i"
          :src="img"
          class="cover-item"
          fit="cover"
        />
      </div>
      <!-- 文章描述项 -->
      <div class="lable-info-wrap">
        <span>{{ art.aut_name }}</span>
        <span>{{ art.comm_count }} 评论</span>
        <span>{{ art.pubdate | dateFormat }}</span>
      </div>
    </template>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    // 文章对象
    art: {
      type: Object,
      required: true
    }
  },
  data() {
    return {}
  },
  created() {
    // this.$router.push('/article/1')
  },
  methods: {},
  computed: {},
  watch: {},
  components: {}
}
</script>

<style lang="less" scoped>
.article-item {
  // 标题
  .van-cell__title {
    font-size: 32px;
    color: #3a3a3a;
  }
  // 右侧区域
  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    padding-left: 25px;
  }
  // 右侧区域中的图片
  .right-cover {
    width: 232px;
    height: 146px;
  }
  .lable-info-wrap span {
    font-size: 22px;
    color: #b4b4b4;
    margin-right: 25px;
  }
  // 下册区域的图片
  .cover-wrap {
    display: flex;
    padding: 30px 0;
    .cover-item {
      flex: 1;
      height: 146px;
      height: 146px;
      &:not(:last-child) {
        padding-right: 4px;
      }
      .cover-item-img {
        width: 100%;
        height: 146px;
      }
    }
  }
}
</style>
